var vedioid='';
function guanzhurequest(types,vedioid){
	wx.request({
		  url: 'http://192.168.220.124/api/vedio/addFocus', //仅为示例，并非真实的接口地址
		  header: {
		      'content-type': 'application/json'
		  },
		  data:{
		  	type:types,
		  	vedioId:vedioid,
		  	stuId:2
		  },
		  success: function(res) {
		  	console.log(res)
		  }
		})
	console.log(types)
	console.log(vedioid)
}
Page({
  data:{
     topPic: [
         'teacher',
          'teacher',
          'teacher',
    ],
    gift: 0,
    urls:null,
    vedioid:null,
    target:'../../img/weiguanzhu.png',
    shadow: 0,
    notice: '本课程是付费课程，请先完成支付',
    shareDesc: [
      {
        img: 'zone',
        name: 'QQ空间',
      },
      {
        img: 'weixin',
        name: '微信好友',
      },
      {
        img: 'friend',
        name: '微信朋友圈',
      },
      {
        img: 'qq',
        name: 'QQ好友',
      },
      {
        img: 'sina',
        name: '新浪微博',
      },
      {
        img: 'copy',
        name: '复制网址',
      },
      {
        img: 'code',
        name: '二维码',
      },
      {
        img: 'link',
        name: '跨屏传输',
      },
    ]
  },
  recharge: function() {
      this.setData({
          notice: '试听以结束，请先完成支付',
      });
  },
  targets:function(){
	var that=this
  	var url1='../../img/weiguanzhu.png';
  	var url2='../../img/yiguanzhu.png';
  	var type
  	var bgurl = this.data.target == url1 ? url2 : url1;
    that.setData( {
      target: bgurl
    });
    if(bgurl===url2){
    	type =1;
    	guanzhurequest(type,vedioid)
    }else{
    	type =0;
    	guanzhurequest(type,vedioid)
    }
  },
  giftShow: function() {
      var gift = this.data.gift;
      if (gift == 0) {
          this.setData({
              gift: 1
          })
      }else{
          this.setData({
              gift: 0
          })
      }
  },
  shareShow: function() {
      this.setData({
            shadow: 1,
      });
  },
  hide: function() {
      this.setData({
            gift: 0,
      });
  },
  shadowHide: function() {
      this.setData({
         shadow: 0,
      });
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
    var that =this
    console.log(options.id)
    console.log(options.url)
    vedioid=options.id
    that.setData({
    	urls:options.url
    })
//  将信息存储在本地
//  wx.setStorage({
//    key: 'key',
//    data: '我是存储数据，',
//    success: function(res) {
//      console.log(res)
//    }
//  })
  },
  onReady:function(){
    // 页面渲染完成
    var that=this
    that.videoContext = wx.createVideoContext('myVideo')
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  }
})